<!-- 订单详情  -->
<template>
    <div class="rightCenter">
        <div class="editTop">
            <div class="editTopTitle" @click="cancelClick()">订单管理</div>
            <i class="icon font_family icon-yema-you"></i>
            <div class="editTopTitle">订单详情</div>
        </div>
        <div class="editList" v-for='(item,index) in dataList' :key='index'>
            <div class="editListName">
                {{item.name}}
            </div>
            <div class="editListInpFont" v-if="item.type == 'etime' || item.type == 'stime'">
                {{item.val | baseDateFun}}
            </div>
            <div class="editListInpFont" v-else-if="item.type == 'prodstatus'">
                {{item.val | prodstatusFun}}
            </div>
            <div class="editListInpFont" v-else>
                {{item.val}}
            </div>
        </div>
    </div>
</template>
<script>
import { mapActions } from "vuex";
import integralRequest from "../../assets/integral";
export default {
  data() {
    return {
      dataList: [
        { name: "产品编号", val: "", type: "id" },
        { name: "产品名称", val: "", type: "pname" },
        { name: "产品价格", val: "", type: "price" },
        { name: "开始时间", val: "", type: "stime" },
        { name: "结束时间", val: "", type: "etime" },
        { name: "产品状态", val: "", type: "prodstatus" }
      ]
    };
  },
  filters: {
    prodstatusFun(val) {
      if (val) {
        if (val == "00") {
          return "在用";
        } else if (val == "01") {
          return "预约";
        } else if (val == "10") {
          return "停用";
        } else if (val == "20") {
          return "退订";
        } else if (val == "30") {
          return "怡宝装";
        } else if (val == "40") {
          return "升级中";
        }
      } else {
        return "暂无";
      }
    }
  },
  created: function() {
    let self = this;
    if (sessionStorage.getItem("TABLIST")) {
      let arr = JSON.parse(sessionStorage.getItem("TABLIST"));
      let routShow = false;
      for (let i = 0; i < arr.length; i++) {
        if (arr[i].name == "订单管理") {
          routShow = true;
        }
      }
      if (!routShow) {
        this.$router.push({
          path: "/login"
        });
        sessionStorage.clear();
        self.$message("暂无权限");
        return;
      }
    }else{
       this.$router.push({
          path: "/login"
        });
        sessionStorage.clear();
        self.$message("暂无权限");
        return;
    }
    self.slistFun();
  },
  watch: {},
  mounted() {},
  methods: {
    async slistFun() {
      let self = this;
      let params = {
        id: self.$route.query.id
      };
      let getParams = `id=${params.id}`;
      let res = await integralRequest.getprodget(getParams);
      if (res.statusCode == 200) {
        if (res.data) {
          let obj = res.data;
          Object.keys(obj).forEach(function(key) {
            self.dataList.forEach((e, i) => {
              if (e.type == key) {
                e.val = obj[key];
              }
            });
          });
        }
      } else {
        self.$message(res.statusMessage);
        self.dataList = [];
      }
    },
    //订单列表
    cancelClick() {
      this.$router.push({
        path: "/home/orderForm"
      });
    },
    ...mapActions([""])
  }
};
</script>
<style scoped>
</style>